package com.colin.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.colin.utils.TimeUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime" , TimeUtils.getTime() , metaObject);
        this.setFieldValByName("lastTime" , TimeUtils.getTime() , metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("lastTime" , TimeUtils.getTime() , metaObject);
    }
}
